<extend name = "Common/baseView"/>
<block name="body">
    <!-- 内容主体区域 -->
    <div id="editPassword" style="padding: 10px;">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
            <legend>修改密码</legend>
        </fieldset>
        <div class="layui-row">
            <div class="layui-col-md5  layui-col-md-offset3">

                <!--要使用的地址-->
                <!--action="{:U('editPassword')}"  method="post"-->
                <form class="layui-form" action="{:U('editPassword')}"  method="post"  >
                    <table class="layui-table" lay-skin="nob" lay-size="lg">
                        <colgroup>
                            <col width="150">
                            <col width="150">
                            <col width="150">
                        </colgroup>
                        <tbody>
                        <tr></tr>
                        <tr>
                            <td>原始密码：</td>
                            <td><input  type="password" name="pwd" lay-verify="required" placeholder="" autocomplete="off"
                                       class="layui-input" style="border-radius: 10px;" id="pwd"></td>
                        </tr>
                        <tr>
                            <td>新&nbsp;&nbsp;密&nbsp;&nbsp;码：</td>
                            <td><input id="newpass" type="password" name="newpwd"  placeholder="" autocomplete="off" class="layui-input" style="border-radius: 10px;"   value=""lay-verify="required"></td>
                        </tr>
                        <tr>
                            <td>确认密码：</td>
                            <td><input id="checkpass" type="password" name="checkpwd"  placeholder="" autocomplete="off"
                                       class="layui-input" style="border-radius: 10px;" lay-verify="checkpwd"></td>
                        </tr>
                        <tr>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <!--lay-submit-->
                                <button class="layui-btn  layui-btn-normal" style="border-radius: 10px;margin-left: 75%;" lay-submit id="save" lay-filter="save">保存</button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>

    </div>
</block>
<block name="js">

<script>

    layui.use('element', function () {
        var element = layui.element;
    });
    layui.use(['form','layer'], function() {
        var form = layui.form;
        var layer = layui.layer;
        form.render();
        form.verify({
            checkpwd:function (value) {
                var newpwd = document.getElementById('newpass').value;
                if(value != newpwd){
                    return '密码不一致';
                }
            }
        });

        form.on('submit(save)', function(data){
//            console.log(data.field); //当前容器的全部表单字段，名值对形式：{name: value}
            $.post("{:U('editPassword')}",data.field,function(res){
                if(res == 1){
                    layer.msg('修改成功');
                    $('input').val('');
                }else{
                    layer.msg(res);
                }

            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

    });

    /*var newpass = document.getElementById('newpass').value;
    var oldpass = document.getElementById('pwd').value;
    var checkpass = document.getElementById('checkpass').value;
    var edit = document.getElementById('save');
    edit.addEventListener('click',function(){
        $.ajax({
            type:'post',
            url:'{:U("editPassword")}',
            data:newpass&oldpass&checkpass,
            success:function(res){
//                        $('#editPassword').html(res);
                alert(2332);
//                        location.href={:U('personInfo')};
            },
            error:function(res){
                layer.msg(res);

            }
        });
    });*/


</script>
</block>